package com.lsj.text;

import com.lsj.Util.JedisConnectionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import redis.clients.jedis.Jedis;

public class jedisText {
    private Jedis jedis;
   @BeforeEach
    void setUp() {
    //1.建立连接
    jedis = JedisConnectionFactory.getJedis();
    //2.设置密码
    //jedis.auth("Lsj1747960024`");
    //3.选择数据库
    jedis.select(0);
    }
    @Test
    void test() {
        //4.存入数据
        String result = jedis.set("name", "lsj");
        System.out.println("result = " + result);
        //5.取出数据
        String name = jedis.get("name");
        System.out.println("name = " + name);
    }
    @AfterEach
    void tearDown() {
    //6.关闭连接
    if (jedis != null) {
        jedis.close();
    }
    }
}
